package org.komarichin.jpa.service;

import org.komarichin.jpa.dao.INewsDAO;
import org.komarichin.jpa.entity.INews;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Admin
 * Date: 24.09.2009
 * Time: 15:17:11
 */
@Service
public class NewsService implements INewsService {

    private static final Logger log = LoggerFactory.getLogger(NewsService.class);

    @Autowired
    protected INewsDAO newsDAO;

    /**
     * {@inheritDoc}
     */
    public INews getNewsById(Long id) {
        INews news = newsDAO.getNewsById(id);
        log.debug("getNewsByID#id : {}, return: {}", id, news);
        return news;
    }


    /**
     * {@inheritDoc}
     */
    public List<INews> getAll() {
        List<INews> news = newsDAO.getAll();
        log.debug("getAll, return: list of news : {}",
                news);
        return news;
    }

    /**
     * {@inheritDoc}
     */
    public void save(INews object) {
        newsDAO.save(object);
    }

    /**
     * {@inheritDoc}
     */
    public void update(INews object) {
        newsDAO.update(object);
    }

    /**
     * {@inheritDoc}
     */
    public void saveOrUpdate(INews object) {
        newsDAO.saveOrUpdate(object);
    }

    /**
     * {@inheritDoc}
     */
    public void delete(INews object) {
        newsDAO.delete(object);
    }

}
